/**
 *  *2010-3-21 上午12:13:20  add 
 */
package com.base.myproject.server.busi;

import java.util.ArrayList;

/**
 * 组织业务权限
 * 实际上就是获得单据的过滤条件，系统默认是根据bcode进行权限分配的。
 * @author Administrator
 *2010-3-21
 * javazgw@gmail.com
 */
public class BusiPermission {
	public static BusiPermission busipermission;
	private BusiPermission()
	{
		
	}
	public static BusiPermission getInstance()
	{
		if(busipermission==null)
		{
			busipermission = new BusiPermission();
		}
		return busipermission;
	}
	public String getBusiPer_SQL(String...strings)
	{
		StringBuffer sbf = new StringBuffer();
		sbf.append("(1=2 ");
		for(String stra :strings)
		{
			
			//systembcode_views 是视图
			//sbf.append(" or bcode like '"+stra+"%'");
			sbf.append(" or bcode in (select bcode from systembcode_view where systembcode like '"+stra+"%')");
		}
		sbf.append(" )");
		return new String(sbf);
	}
	public String getBusiPer_SQL(ArrayList<String> al)
	{
		StringBuffer sbf = new StringBuffer();
		sbf.append("(1=2 ");
		for(String stra :al)
		{
			//systembcode_views 是视图
			//sbf.append(" or bcode like '"+stra+"%'");
			sbf.append(" or bcode in (select bcode from systembcode_view where systembcode like '"+stra+"%')");
			
		}
		sbf.append(" )");
		return new String(sbf);
	}
	public static void main(String[] argv)
	{
		System.out.println(BusiPermission.getInstance().getBusiPer_SQL("99","88"));
	}
}
